from typing import Dict
from pydantic import BaseModel

from pydantic import BaseModel, Field
from typing import Optional, Any


class Msg(BaseModel):
    msg_id: str
    create_time: int
    ctype: int
    content: str
    from_user_id: str
    from_user_nickname: str
    to_user_id: str
    to_user_nickname: str
    other_user_id: str
    other_user_nickname: str
    my_msg: bool
    self_display_name: Optional[str] = None
    is_group: bool
    is_at: bool
    actual_user_id: Optional[str] = None
    actual_user_nickname: Optional[str] = None
    at_list: Optional[Any] = None  # 使用 Optional[Any] 来表示可能为 None 或其他类型的值
    _prepare_fn: Optional[Any] = None
    _prepared: bool

    def get(self, name, default):
        return getattr(self, name) if hasattr(self, name) else default


class WXMessageIn(BaseModel):
    type: int
    content: str
    isgroup: bool
    msg: Msg
    no_need_at: Optional[bool] = False
    origin_ctype: int
    # openai_api_key: Optional[str] = None
    # gpt_model: Optional[str] = None
    session_id: str
    receiver: str
